package com.copsoftware.struts.action;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.copsoftware.struts.forms.BaseActionForm;
import com.copsoftware.support.json.JSONArray;

public class CargarGridAction extends BaseAction {

	@Override
	public ActionForward process(ActionMapping mapping,
			BaseActionForm baseForm, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
			
		List lista  = new ArrayList();
		Objeto obj = new Objeto();
		obj.iso = "1";
		obj.name = "Nombre";
		Objeto obj1 = new Objeto();
		obj1.iso = "2";
		obj1.name = "Nombre2";
		lista.add(obj);
		lista.add(obj1);
		JSONArray jsonArray = new JSONArray(lista);
		
		
		PrintWriter pw = response.getWriter();

		
		pw.write("{\"page\": 1, " );
		pw.write("\"total\" : 2, ");								
		pw.write("\"rows\": [ \n {id:'"+obj.iso+"',cell : [ '"+obj.iso+"','"+obj.name+"']}");  		  
		pw.write(" , {id:'"+obj1.iso+"',cell : [ '"+obj1.iso+"','"+obj1.name+"']}]} ");  		  
		pw.flush();  
		pw.close();
		
		String cadena = " \" ";
		
		return null;
	}

}

class Objeto{
	String iso;
	String name;
}
